package Utilsbao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Created by lanou1 on 18/1/4.
 */
public class JDBCUtils {
    private static String Driver = "com.mysql.jdbc.Driver";
    private static String Url = "jdbc:mysql://localhost:3306/lanou?characterEncoding=UTF-8&useSSl=true";
    private static String User = "root";
    private static String Pwd = "root";
    private static Connection conn = null;
    private static PreparedStatement ps = null;

    public static PreparedStatement getConn(String sql) {

        try {
            Class.forName(Driver);
            conn = DriverManager.getConnection(Url, User, Pwd);
            ps = conn.prepareStatement(sql);
        } catch (Exception var2) {
            var2.printStackTrace();
        }

        return ps;
    }

    public static void closeAll() {
        try {
            conn.close();
        } catch (SQLException var1) {
            var1.printStackTrace();
        }

    }
}
